package com.sunshine.ssm.controller;

import com.sunshine.ssm.util.ImageUploadUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Demo class
 *
 * @author WeiHong
 * @date 2018/8/10
 */
@Controller
@RequestMapping("ckEditor")
public class CkEditorController {

    @RequestMapping("index/ckeditor")
    public String index() {
        return "/ckeditor/ckeditor";
    }

    /**
     * ckeditor图片上传
     *
     * @param request
     * @param response
     * @Title imageUpload
     */
    @RequestMapping("imageUpload")
    public void imageUpload(HttpServletRequest request, HttpServletResponse response) {
        String DirectoryName = "WEB-INF/static/CKEditor/tmp/upload/";
        try {
            ImageUploadUtil.ckeditor(request, response, DirectoryName);
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
